//package com.example.mytestdemo.view
//
//import android.animation.ValueAnimator
//import android.content.Context
//import android.graphics.Canvas
//import android.graphics.Color
//import android.graphics.Paint
//import android.util.AttributeSet
//import android.view.View
//import android.view.animation.LinearInterpolator
///**
// *@Author tgw
// *@Date 2023/11/10
// *@describe
// */
//class MarqueeView1 : View {
//
//    private var text: String? = null
//    private var textSize: Float = 48f
//    private var textColor: Int = Color.RED
//    private var textGap: Float = 100f
//    private var marqueeAnimator: ValueAnimator? = null
//
//    constructor(context: Context) : super(context) {
//        init()
//    }
//
//    constructor(context: Context, attrs: AttributeSet) : super(context, attrs) {
//        init()
//    }
//
//    private fun init() {
//      val  MarqueeAnimator = ValueAnimator.ofFloat(0f, textGap).apply {
//            duration = 5000
//            repeatCount = ValueAnimator.INFINITE
//            interpolator = LinearInterpolator()
//            addUpdateListener {
//                offset = it.animatedValue as Float
//                invalidate()
//            }
//        }
//        MarqueeAnimator?.start()
//    }
//
//    override fun onMeasure(widthMeasureSpec: Int, heightMeasureSpec: Int) {
//        val textWidth = paint.measureText(text)
//        val textHeight = paint.fontMetrics.bottom - paint.fontMetrics.top
//        setMeasuredDimension(textWidth.toInt(), textHeight.toInt())
//    }
//
//    override fun onDraw(canvas: Canvas) {
//        canvas.clipRect(0f, 0f, textGap + measuredWidth, measuredHeight.toFloat())
//        val textHeight = paint.fontSpacing
//        val verticalCenter = measuredHeight / 2f + textHeight / 2f
//        canvas.drawText(text, -offset, verticalCenter, paint)
//        canvas.drawText(text, textGap + measuredWidth - offset, verticalCenter, paint)
//    }
//}